package apa.data.samples;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class RowCountScanner {
	public static void main(String[] args) {
		if (args.length != 1) {
			System.out.println("Usage: java WordCount inputFile");
			System.exit(0);
		}
		try {
			Scanner input = new Scanner(new File(args[0]));
			int nrows = 0, minc = Integer.MAX_VALUE, maxc = Integer.MIN_VALUE;
			String line;
			while (input.hasNextLine()) {
				line = input.nextLine();
				++nrows;
				int nc = line.split(",").length;
				if (nc < minc)
					minc = nc;
				if (nc > maxc)
					maxc = nc;
			}
			input.close();
			System.out.println("Rows: " + nrows);
			System.out.println("Min columns: " + minc);
			System.out.println("Max columns: " + maxc);
		} catch (IOException e) {
			System.out.println(e.toString());
		}
	}
}
